<template>
	<div class="page-container">
	    <el-dialog :title="title" width="60%"    :visible.sync="coreStockDetailViewVisible"     :before-close="handleClose" >
		<div class="gk-layout-container">
		
			<div class="gk-layout-header">
				<s-reflash :reflash=false :excel=true  @exportExcel="handleExportExcelAll"> 
				</s-reflash>
			 </div>
			<div class="gk-layout-main" style="height:500px" >

				<my-table  ref="zttableDetList"  :data="pageResult"  :loading="loading"  >
					<el-table-column :label="$t('action.desc')" width="50" header-align="center" align="center">
						<template slot-scope="scope"> {{scope.$index+1}} </template>
					</el-table-column> 
					<column prop="itemId" label="物料名称"     :formatter="itemFilter"/>
					<column prop="batchNo" label="批次号"/>  
					<column prop="old" label="原有数量"/>  
					<column prop="now" label="现有数量"/>
					<column prop="id" label="单位"    :formatter= "selectionFormat1" /> 
				</my-table>
			</div>
			
		</div>
	</el-dialog>
</div>

</template>

<script> 
	import KtButton from "@/views/Core/KtButton"
	import MyTable from "@/views/Core/MyTable"
	import Column from "@/views/Core/Column"
	import { format } from "@/utils/datetime"
    import {getItemName,dictsFormat,getItem} from "@/utils/myUtil"
    import SReflash from "@/components/Kj/SReflash"

	export default {

		components: {
			KtButton,
			Column,
			MyTable,
			SReflash
		},
		props: {
			filters: Object,
			coreStockDetailViewVisible: {
				type: Boolean
			},
			title:""
		},
		data() {
			return {
				
				loading: false,  
				pageResult: [], 
			}
		},
		methods: {
			 
			// 获取分页数据
			findPage: function (data) {
				  if(data!=-1){
				this.filters.pageNum=data	
			} 
				this.$api.pk.hisPage(this.filters).then((res) => {
					this.pageResult = res.data
				}) 
			},


		  	selectionFormat1: function (row, column, cellValue, index) {
			 
				var i=getItem(row.itemId)
				return dictsFormat( "units",i.u)
      		},
			itemFilter: function (row, column, cellValue, index) {

				return getItemName(cellValue)
			},
		 	   handleExportExcelAll: function () {
					this.$emit('handleExportExcel', this.filters)
				},
			
			 
		   handleClose: function () {
			this.$emit('coreStockDetailListHidden', {})
		},
 
			
		},
		
		mounted() {
			 
		
		},
		watch:{

			coreStockDetailViewVisible(n,o){

				if(n===true){
					this.findPage(-1);
				}
				
			}


		}
	}
</script>

<style scoped>

</style>